//
//  KSAlertController.swift
//  ANOA
//
//  Created by 邱仙凯 on 2023/2/11.
//  Copyright © 2023 zwb. All rights reserved.
//   左边搜索框 右边日期的固定搜索

import UIKit

class ComListVC: UIViewController {
    
    var startDate = Date.firstDateOfMonth
    var endDate = Date.today
    
    var page = 1
    var isOpenArr = [Bool]()
    var tableView: UITableView!
    
    
    lazy var filterBanner:SearchDayRangeV = {
        let v = SearchDayRangeV(frame: CGRect(x:0,y:0,width: KSGlobal.screenW,height: 50))
        return v
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let searchItem = UIBarButtonItem(image: UIImage(named: "guolv"), style: .done, target: self, action: #selector(search))
        
        navigationItem.rightBarButtonItems = [searchItem]
        edgesForExtendedLayout = UIRectEdge()
        
        
        tableView = UITableView()
        tableView.tableHeaderView = filterBanner
        tableView.separatorStyle = .none
        tableView.backgroundColor = Theme.GREY
        tableView.tableFooterView = UIView(frame: CGRect.zero)
        tableView.estimatedRowHeight = 100
        tableView.rowHeight = UITableView.automaticDimension
        view.addSubview(tableView)
        
        tableView.snp.makeConstraints { (make) in
            make.top.equalTo(self.view.snp.top)
            make.left.equalTo(self.view)
            make.right.equalTo(self.view)
            make.bottom.equalTo(self.view)
        }
        if #available(iOS 15.0, *) {
            tableView.sectionHeaderTopPadding = 0
        }
        self.tableView.mj_header = KSRefreshHeader {
            self.tableView.mj_header?.beginRefreshing()
        }
        self.tableView.mj_footer = KSRefreshFooter {
            self.footerRefresh()
        }
    }
    
    //下拉刷新操作
    @objc func headerRefresh() {
        
    }
    
    //上拉加载操作
    @objc func footerRefresh() {
        
    }
    
    func segmentAction(_ sender: UISegmentedControl) {
        
    }
    
    @objc func search() {
        
    }
}
class ComListCell: UITableViewCell {
    
    
    lazy  var bg:GradientView = {
        let v = GradientView()
        v.backgroundColor = .white
        v.layer.cornerRadius = 8
        v.layer.masksToBounds = true
        return v
    }()
    
    lazy var titleL:UILabel = {
        let v = UILabel()
        v.numberOfLines = 0
        v.textAlignment = .center
        v.textColor = UIColor(kshex: "#2A304A")
        v.text = "-"
        v.font = UIFont.boldSystemFont(ofSize: 18)
        return v
    }()
    
    lazy var subtitleL:UILabel = {
        let v = UILabel()
        v.numberOfLines = 0
        v.textAlignment = .center
        v.textColor = UIColor(kshex: "#8991B0")
        v.text = "-"
        v.font = UIFont.systemFont(ofSize: 15)
        return v
    }()
    
    var img:UIButton = {
        var v = UIButton()
         v.layer.cornerRadius = 8
        v.layer.masksToBounds = true
        v.setBackgroundImage(UIImage(named: "gg_pig"), for: .normal)
        return v
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.contentView.backgroundColor = .clear
        self.backgroundColor = .clear
        self.contentView.addSubview(bg)

        bg.addSubview(titleL)
        bg.addSubview(subtitleL)
        bg.addSubview(img)
        bg.snp.makeConstraints { make in
            make.edges.equalTo(UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5))
        }
        titleL.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(8)
            make.top.equalToSuperview().offset(15)
        }
        subtitleL.snp.makeConstraints { make in
            make.top.equalTo(titleL.snp.bottom).offset(19)
            make.bottom.equalToSuperview().offset(-15)
            make.left.equalTo(titleL)
        }
        img.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.width.height.equalTo(80)
            make.right.equalToSuperview().offset(-10)
        }
    }
    
    
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
